package edu.mit.media.fv.layers
{
	import edu.mit.media.fv.blocks.*;
	import edu.mit.media.fv.components.*;
	import edu.mit.media.fv.events.*;
	import edu.mit.media.fv.fluidspace.*;
	import edu.mit.media.fv.icons.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.filters.*;
	import flash.geom.Rectangle;
	import flash.text.*;

	public class SimpleLayer extends Layer
	{
		public function SimpleLayer(x:int=0, y:int=0, width:int=650, height:int=100, icon:DisplayObject = null)
		{
			super(x, y, width, height, icon);
			
			this._wall = new Sprite();
			this.addChild(this._wall);
			
			var format:TextFormat = new TextFormat();
			format.align = TextFormatAlign.LEFT;
			format.bold = true;
			format.font = "Arial";
			format.size = 12;
			format.color = 0x000000;
			this._label = new TextField();
			this._label.defaultTextFormat = format;
			this._label.type = TextFieldType.DYNAMIC;
			this._label.selectable = false;
			this._label.x = MARGIN;
			this._label.y = MARGIN;
			this._label.width = width;
			this._label.height = HEADER_HEIGHT-MARGIN*2;
			//this.addChild(this._label);
			
			
			this._canvas = new Handle(this);
			this.addChild(this._canvas);
		}
		public override function reform():void{
			this._viewbounds = new Rectangle(
				0, 0,
				this.layerWidth, this.layerHeight);
			
			this._label.x = 0;
			this._label.width = this.layerWidth;
			this._label.height = this.layerHeight;
			this._label.y = 0;
			
			var format:TextFormat = new TextFormat();
			format.align = "center";
			format.bold = true;
			format.font = "Arial";
			format.size = this.layerHeight*0.80;
			format.color = this.backgroundColor;
			this._label.setTextFormat(format);
			
			this._wall.graphics.clear();
			this._wall.graphics.beginFill(0xFFFFFF, 0.01);
			//this._wall.graphics.lineStyle(1,0xFFFFFF,0.70,true);
			this._wall.graphics.drawRoundRect(0,0,this.layerWidth, this.layerHeight, 15,15);
			this._wall.graphics.endFill();
			
			var filter:BevelFilter = new BevelFilter(4, 45, 0, 1, this.backgroundColor, 1);
			this._wall.filters = [filter];
			
			
			Handle(this._canvas).setBounds(0,0,this.layerWidth, this.layerHeight);
			
			
		}
		public override function addBlock(block:Block):void{
			super.addBlock(block);
			if(block == null){ return;}
			this._canvas.addChild(block);
			block.y = 2;
			block.diameter = this._viewbounds.height;
		}
		
	}
}